import { applyDecorators, SetMetadata, UseGuards } from '@nestjs/common'
import { ApiBearerAuth } from '@nestjs/swagger'
import { AuthGuard } from '@nestjs/passport'
import { RolesGuard } from './roles.guard'

export const Auth = (obj: string, act: string) => {
  return applyDecorators(
    // applyDecorators合并装饰器，
    SetMetadata('roles', { obj, act }),
    UseGuards(AuthGuard('jwt'), RolesGuard),
    ApiBearerAuth()
  )
}
